package com.gxuwz.attend.context;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 访问IoC容器工具
 * @Author amu_1115@126.com
 *
 */
public class AppContext {
    private static ApplicationContext CONTEXT;
    private static final String CONFIGURATION_XML ="classpath:applicationContext.xml";
    //静态代码块
    static {
        CONTEXT =new ClassPathXmlApplicationContext(CONFIGURATION_XML);
    }

    /**
     * 从IOC容器中获取Bean
     * @param tClass
     * @return
     * @param <T>
     */
    public static  <T>T getBean(Class<T> tClass){
       return CONTEXT.getBean(tClass);
    }


}
